home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pas2c.zip
/
PATCHTPC.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-01-04
|
6KB
|
166 lines
{
Problem with Turbo Pascal V4.0 - Inter-Language Linking
Product Serial Number: A4B0071808
The compiler gives an error 51 "Invalid PUBLIC definition" when using OBJ
files that have PUBLIC symbols that are not defined as "external" declarations
in Pascal. This is in accordance with the manual, page 617.
I am attempting to use Turbo C (serial number: X1D0080047) subprograms with
Turbo Pascal V4.0. Turbo C intrinsic functions have a '@' character appended
to the name (eg. LDIV@). If the C code requires the use of such an intrinsic,
it generates the appropriate call. I have extracted the intrinsic functions
from the C run-time library, and have corrected the CODE and DATA segments to
properly convert and load with Turbo Pascal. Unfortunately, the '@' sign is
an illegal character in Turbo Pascal identifiers. Therefore, references to
the Turbo C intrinsic functions cannot be satisfied, because the Turbo Pascal
OBJ capability requires identification of ALL public symbols, and the intrinsic
identifiers cannot be syntactically defined.
I believe that the requirement for all publics in OBJ files to be
declared in the using Pascal program to be to restrictive. It is definitely
putting a damper on our development efforts. The implication of this problem
is that some C code, even if it does not use ANY of the documented C library
functions cannot be made to work with Turbo Pascal. C code using long divide,
long shifting, structure assignment and structure passing cannot be used with
Turbo Pascal. I use structure passing in C programs extensively, and consider
this a crucial feature.
Sincerely Yours,
Martin Weigel,
Chameleon Typeface Foundry Inc.
Suite 2720,
145 King Street West,
Toronto, Ontario,
Canada M5H 2J8
(416) 367-3668
#: 113334 S2/Turbo Pascal v.4
15-Dec-87 21:47:58
Sb: #113316-Language Linking Problem
Fm: Kim Kokkonen 72457,2131
To: Martin Weigel 76237,733
Martin - I'm not so sure the patch will be easy, or even possible. '@' is now
an operator in Turbo Pascal 4.0 (meaning "address of"), and without disabling
that feature of the language, it will be really tricky to allow it in
identifier names. And modifying the linker to not require a matchup between
EXTRNs and Pascal identifiers would be even harder.
(speaking as a hacker)
-Kim
#: 113407 S2/Turbo Pascal v.4
16-Dec-87 14:11:59
Sb: #113316-Language Linking Problem
Fm: John Sieraski (Borland) 76117,2022
To: Martin Weigel 76237,733
Martin, Like Kim has already mentioned, a correction to the inter-language
linking problems that you have encountered would require a lot more than a
patch. I have submitted a suggestion to our development folks that they
consider making inter-language linking with Borland languages easier. I know
that inter-language linking is an important issue and Borland is definitely
working on a solution for this. For now, there isn't any solution available,
but in the future I'm sure there will be.
--John
#: 113409 S2/Turbo Pascal v.4
16-Dec-87 14:15:00
Sb: #PUBLIC Linkage
Fm: Kim Kokkonen 72457,2131
To: Martin Weigel 76237,733
Well Martin, you got my curiosity up, and I think I've got a patch that will do
the trick for you. I've tested this with some of our assembly language, adding
extra PUBLICs and naming things ending with '@', but I haven't tested it with
actual C code. In my tests, I haven't found any problems. The only limitation
is that the patch needs to use a little extra code space, so some of the other
PUBLIC errors won't give as descriptive an error message because I had to
overwrite that code.
The patch works only on TPC.EXE. Make a backup copy of the compiler first,
because the patch program will overwrite TPC.EXE. It will make the copyright
version number appear as "4.pi" so you'll know you're using the patched
version. I'd be curious to hear if it works for you.
See the following message for the patching program.
-Kim
#: 113421 S2/Turbo Pascal v.4
16-Dec-87 15:05:49
Sb: #113409-#PUBLIC Linkage
Fm: John Sieraski (Borland) 76117,2022
To: Kim Kokkonen 72457,2131 (X)
Martin, I guess that Kim has proved that maybe a patch _is_ all that's
required to solve the inter-language problems you were having. I'll be lurking
to see if your problems are cured with the patch. Where there's a will there's
a way. I'm gonna try the patch out pronto. Thanks Kim, you and Brian never
cease to impress me.
--John
#: 113461 S2/Turbo Pascal v.4
16-Dec-87 21:28:21
Sb: #113421-PUBLIC Linkage
Fm: Kim Kokkonen 72457,2131
To: John Sieraski (Borland) 76117,2022 (X)
You shouldn't thank me until we know whether it really works for his "C"
problem. I'm afraid that there may be some hidden effect that hasn't shown up
in the limited testing I did. We'll see...
-Kim
Kim: Thanks for the patch. I missed the message about the patch the first
time through (my option mask settings were wrong!). I will try it out
right now!
Many Thanks
Martin.
}
program PatchTPC;
var f : file of Byte;
procedure Patch(loc : LongInt; o, n : Byte);
var b : Byte;
begin
Seek(f, loc); Read(f, b);
if b <> o then begin
WriteLn('Data should be ', o, ' but is ', b); Halt(1);
end;
Seek(f, loc); Write(f, n);
end;
begin
Assign(f, 'TPC.EXE'); Reset(f);
if FileSize(f) <> 41790 then begin
WriteLn('Unknown version of TPC.EXE'); Halt(1);
end;
Patch($7AE3,$2F,$29);
Patch($7AEA,$28,$22);
Patch($7B13,$B8,$58);
Patch($7B14,$33,$EB);
Patch($7B15,$00,$ED);
Patch($9068,$30,$E3);
Close(f);
end.